package com.threefish.modules.report.entity;

import org.nutz.dao.entity.annotation.*;
import org.nutz.json.Json;
import org.nutz.lang.random.R;

import java.io.Serializable;
import java.sql.Timestamp;

/**
 * @author 黄川 huchuc@vip.qq.com
 * @date: 2018/9/6
 */
@Table("sys_report_file")
@TableIndexes(@Index(fields = "reportName", name = "unique_reportName"))
public class ReportFileDO implements Serializable {

    private static final long serialVersionUID = 1L;

    @Name
    @Prev(els = @EL("$me.uuid()"))
    String uuid;

    @Column
    @Comment("报表名称")
    String reportName;

    @Column
    @Comment("是否禁用")
    Boolean disabled;

    @Column
    @Comment("报表内容")
    @ColDefine(type = ColType.TEXT)
    String reportContent;

    @Column
    @Comment("操作时间")
    @Prev(els = @EL("$me.now()"))
    @ColDefine(type = ColType.TIMESTAMP)
    private Timestamp opAt;

    public Timestamp now() {
        return new Timestamp(System.currentTimeMillis());
    }

    public String uuid() {
        return R.UU16();
    }

    public Timestamp getOpAt() {
        return opAt;
    }

    public void setOpAt(Timestamp opAt) {
        this.opAt = opAt;
    }


    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public String getReportName() {
        return reportName;
    }

    public void setReportName(String reportName) {
        this.reportName = reportName;
    }

    public Boolean isDisabled() {
        return disabled;
    }

    public void setDisabled(Boolean disabled) {
        this.disabled = disabled;
    }

    public String getReportContent() {
        return reportContent;
    }

    public void setReportContent(String reportContent) {
        this.reportContent = reportContent;
    }

    @Override
    public String toString() {
        return String.format("/*%s*/%s", super.toString(), Json.toJson(this));
    }
}
